package com.cct.digitalarchapi.controller;

import com.alibaba.fastjson2.JSONObject;
import com.cct.digitalarchapi.common.CommonUtil;
import com.cct.digitalarchapi.common.Response;
import com.cct.digitalarchapi.pojo.ArchCategory;
import com.cct.digitalarchapi.pojo.ArchDeptHotpoint;
import com.cct.digitalarchapi.service.ArchCategoryService;
import com.cct.digitalarchapi.service.ArchDeptHotpointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @FileName ArchCategoryController
 * @Description 热点控制器
 * @Author Created by chenmingzhe
 * @Date 2023/11/19
 **/
@RestController
@RequestMapping(value = "/hotpoint")
public class ArchDeptHotpointController {
    @Autowired
    private ArchDeptHotpointService archDeptHotpointService;
    @Autowired
    private CommonUtil commonUtil;
    /**
     * 新增热点标签
     */
    @RequestMapping(value = "/addHotpoint",method = RequestMethod.POST)
    public Response addHotpoint(@RequestBody ArchDeptHotpoint archDeptHotpoint){
        commonUtil.recordOperateLog("新增热点标签名称为"+archDeptHotpoint.getArchDeptHotName()+"的热点标签");
        return  archDeptHotpointService.addHotpoint(archDeptHotpoint);
    }
    /**
     *删除热点标签
     */
    @RequestMapping(value = "/deleteHotpoint",method = RequestMethod.POST)
    public Response deleteHotpoint(@RequestBody JSONObject obj){
        int archDeptHotId = obj.getInteger("archDeptHotId");
        commonUtil.recordOperateLog("删除热点标签为Id"+archDeptHotId+"的热点标签");
        return  archDeptHotpointService.deleteHotpoint(archDeptHotId);
    }

    @RequestMapping(value = "/qryHotpoint",method = RequestMethod.POST)
    public Response qryHotpoint(@RequestBody JSONObject obj){
        //部门编码加档案编码 例如01-02
        int pageNum=obj.getInteger("pageNum");
        int pageSize=obj.getInteger("pageSize");
        String archDeptCateCode=obj.getString("archDeptCateCode");
        return  archDeptHotpointService.qryHotpoint(pageNum,pageSize,archDeptCateCode);
    }
}
